def usernameCHECK(userName):
    lenght = len(userName)
    if lenght < 6 or lenght > 10:
        raise Exception('用户长度必须为6~10位！')
def passwordCheck(password):
    length = len(password)
    if length >= 8 and length <=16:
        if password.isalnum():
            if password.isdigit() or password.isalpha():
                paise Exception('密码只能包含数字和字母！')
        else:
            raise  Exception('密码只能包含数字和字母！')
    else:
        raise  Exception('密码长度必须为8~16位！')
while True:
    try:
        userName = input('请输入用户名')
        usernameCHECK(userName)
        password = input('请输入密码')
        passwordCheck(password)
        print('注册成功！')
        break
    except Exception as e:
        print(e)
